package com.eii.gateway;

import cn.hutool.core.util.StrUtil;
import com.eii.common.lb.annotation.EnableBaseFeignInterceptor;
import com.eii.gateway.utils.ReactiveAddrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

@Slf4j
@EnableFeignClients
@EnableBaseFeignInterceptor
@EnableDiscoveryClient
@SpringBootApplication
public class EiiGatewayApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext application = SpringApplication.run(EiiGatewayApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = ReactiveAddrUtil.getLocalAddr();
        String port = StrUtil.nullToEmpty(env.getProperty("server.port"));
        String path = StrUtil.nullToEmpty(env.getProperty("server.servlet.context-path"));
        log.info("\n----------------------------------------------------------\n\t" +
                "Application  is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + path + "/\n\t" +
                "External: \thttp://" + ip + ":" + port + path + "/\n\t" +
                "Swagger文档: http://" + ip + ":" + port + path + "/doc.html\n" +
                "----------------------------------------------------------");
        log.info("program is running...");
    }
}
